import axios from "../utils/http"

//修改头像
export function modifyAvatar(file) {
    let obj = new FormData()
    obj.append("file",file)
    return axios.post(`api/pcUser/updata/userAvatar`,obj)
}

//修改个人信息
export function modifyName(user) {
    let obj ={
        "nickname":user,
    }
    return axios.post(`/api/pcUser/update/userInfo`,obj)
}

//获取验证码
export function getCode(num) {

    return axios.get(`/api/pcUser/short-message/vcode/${num}`)
}
//修改用户手机
export function modifyPhone(num,code) {
    let obj ={
        "mobile":num,
        "code":code,
    }
    return axios.post(`/api/pcUser/update/userMobile`,obj)
}
//获取修改密码的验证码
export function getPwdCode(num) {

    return axios.get(`/api/pcUser/edit-password/send/code/${num}`)
}

//修改密码
export function modifyPwd(oldPwd,newPwd,checkNewPwd,mobile,code) {
    let pwdObj = new URLSearchParams()
    pwdObj.append("oldPassword",oldPwd)
    pwdObj.append("newPassword",newPwd)
    pwdObj.append("checkNewPassword",checkNewPwd)
    pwdObj.append("mobile",mobile)
    pwdObj.append("code",code)
    return axios.post(`api/pcUser/update/userPassword`,pwdObj)
}